public class ExtendsDemo19 {
    public static void main(String[] args) {
        Pig1 pig1 = new Pig1("荷兰猪", 10);
    }
}


class Animal1 {
    private String name;
    private int age;

    public Animal1(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void eat() {
        System.out.println("吃");
    }
}


class Pig1 extends Animal1 {
    // 父类的行为满足不了子类，那么我们就重写


    public Pig1(String name, int age) {
        super(name, age);// super代表父类的有参构造，让父类帮我们初始化属性
    }

    @Override
    public void eat() {
        System.out.println("猪吃玉米");
    }
}

class Cat1 extends Animal1 {
    public Cat1(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println("吃国产猫粮");
    }
}
